﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class BattleUnit : MonoBehaviour
{
    // 单位属性
    [SerializeField] protected int MaxHP = 100;
    [SerializeField] protected int MaxSP = 10;
    // FS:必杀槽
    [SerializeField] protected int MaxFS = 3;
    [SerializeField] protected int ATK = 10;
    protected int CurrentHP = 0;
    protected int CurrentSP = 0;
    protected int CurrentFS = 0;
    // 单位阵营，待有关卡加载流程后让流程写入
    [SerializeField] protected UnitCamp camp;
    // 单位编号，区分玩家队伍角色的前场/待机，与敌人的前场/待机，0为前场，1为待机1号位，2为待机2号位
    [SerializeField] protected int UnitSerialNumber;

    private void Awake()
    {
        CurrentHP = MaxHP;
    }

    public void GetDamage(int damage)
    {
        // 逻辑
        if (CurrentHP >= damage)
        {
            CurrentHP -= damage;
        }
        else
        {
            CurrentHP -= CurrentHP;
        }
        if (CurrentHP == 0)
            Death();
        // 表现【待完善】

    }

    // 单位死亡逻辑
    public void Death()
    {
        // 向关卡管理器发送对应阵营单位计数减一的请求
        GameObject.Find("LevelManager").GetComponent<LevelManager>().UnitReduce(camp);
    }
}
